/**************************************************************************************************
	$Header: /pub/cvsroot/mydns/src/lib/str.c,v 1.7 2003/04/24 22:59:23 bboy Exp $

	Copyright (C) 2002-2003  Don Moore <bboy@bboy.net>

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at Your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
**************************************************************************************************/

#include "mydns.h"


/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	MYDNS_CLASS_STR
	Returns a pointer to a static string describing the specified query/response protocol class.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
char *
mydns_class_str(c)
	dns_class_t c;
{
	static char buf[4];

	switch (c)
	{
		case DNS_C_IN:     return ("IN");
		case DNS_C_CHAOS:  return ("CHAOS");
		case DNS_C_HESIOD: return ("HESIOD");
		case DNS_C_ANY:    return ("ANY");
	}
	snprintf(buf, sizeof(buf), "%03d", c);
	return (buf);
}
/*--- mydns_class_str() -------------------------------------------------------------------------*/


/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	MYDNS_QTYPE_STR
	Returns a pointer to a static string describing the specified query/response type.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
char *
mydns_qtype_str(qtype)
	dns_qtype_t qtype;
{
	static char buf[4];

	switch (qtype)
	{
		case DNS_T_A: return ("A");
		case DNS_T_NS: return ("NS");
		case DNS_T_MD: return ("MD");
		case DNS_T_MF: return ("MF");
		case DNS_T_CNAME: return ("CNAME");
		case DNS_T_SOA: return ("SOA");
		case DNS_T_MB: return ("MB");
		case DNS_T_MG: return ("MG");
		case DNS_T_MR: return ("MR");
		case DNS_T_NULL: return ("NULL");
		case DNS_T_WKS: return ("WKS");
		case DNS_T_PTR: return ("PTR");
		case DNS_T_HINFO: return ("HINFO");
		case DNS_T_MINFO: return ("MINFO");
		case DNS_T_MX: return ("MX");
		case DNS_T_TXT: return ("TXT");
		case DNS_T_RP: return ("RP");
		case DNS_T_AFSDB: return ("AFSDB");
		case DNS_T_X25: return ("X25");
		case DNS_T_ISDN: return ("ISDN");
		case DNS_T_RT: return ("RT");
		case DNS_T_NSAP: return ("NSAP");
		case DNS_T_NSAP_PTR: return ("NSAP_PTR");
		case DNS_T_SIG: return ("SIG");
		case DNS_T_KEY: return ("KEY");
		case DNS_T_PX: return ("PX");
		case DNS_T_GPOS: return ("GPOS");
		case DNS_T_AAAA: return ("AAAA");
		case DNS_T_LOC: return ("LOC");
		case DNS_T_NXT: return ("NXT");
		case DNS_T_EID: return ("EID");
		case DNS_T_NIMLOC: return ("NIMLOC");
		case DNS_T_SRV: return ("SRV");
		case DNS_T_ATMA: return ("ATMA");
		case DNS_T_NAPTR: return ("NAPTR");
		case DNS_T_KX: return ("KX");
		case DNS_T_CERT: return ("CERT");
		case DNS_T_A6: return ("A6");
		case DNS_T_DNAME: return ("DNAME");
		case DNS_T_SINK: return ("SINK");
		case DNS_T_OPT: return ("OPT");
		case DNS_T_TSIG: return ("TSIG");
		case DNS_T_IXFR: return ("IXFR");
		case DNS_T_AXFR: return ("AXFR");
		case DNS_T_MAILB: return ("MAILB");
		case DNS_T_MAILA: return ("MAILA");
		case DNS_T_ANY: return ("ANY");
		default: break;
	}
	snprintf(buf, sizeof(buf), "%03d", qtype);
	return (buf);
}
/*--- mydns_qtype_str() -------------------------------------------------------------------------*/


/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	MYDNS_OPCODE_STR
	Returns a pointer to a static string describing the specified query/response opcode.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
char *
mydns_opcode_str(opcode)
	dns_opcode_t opcode;
{
	static char buf[4];

	switch (opcode)
	{
		case DNS_OPCODE_QUERY:  return ("QUERY");
		case DNS_OPCODE_IQUERY: return ("IQUERY");
		case DNS_OPCODE_STATUS: return ("STATUS");
	}
	snprintf(buf, sizeof(buf), "%03d", opcode);
	return (buf);
}
/*--- mydns_opcode_str() ------------------------------------------------------------------------*/


/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	MYDNS_RCODE_STR
	Returns a pointer to a static string describing the specified return code.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
char *
mydns_rcode_str(rcode)
	dns_rcode_t rcode;
{
	static char buf[4];

	switch (rcode)
	{
		case DNS_R_NOERROR:  return ("NOERROR");
		case DNS_R_FORMERR:  return ("FORMERR");
		case DNS_R_SERVFAIL: return ("SERVFAIL");
		case DNS_R_NXDOMAIN: return ("NXDOMAIN");
		case DNS_R_NOTIMP:   return ("NOTIMP");
		case DNS_R_REFUSED:  return ("REFUSED");
		case DNS_R_YXDOMAIN:	return ("YXDOMAIN");
		case DNS_R_YXRRSET:	return ("YXRRSET");
		case DNS_R_NXRRSET:	return ("NXRRSET");
		case DNS_R_NOTAUTH:	return ("NOTAUTH");
		case DNS_R_NOTZONE:	return ("NOTZONE");
		case DNS_R_BADVERS:	return ("BADVERS");
	}
	snprintf(buf, sizeof(buf), "%03d", rcode);
	return (buf);
}
/*--- mydns_rcode_str() -------------------------------------------------------------------------*/

/* vi:set ts=3: */
